<template slot-scope="scope">
  <div>
    <el-table
    :data="tableData"
    stripe
    style="width: 100%">
    <el-table-column
    prop="thesisLayoutId"
    label="论文规范编号"
    >
  </el-table-column>

  <el-table-column
  prop="thesisLayoutName"
  label="论文规范名称"
  >
</el-table-column>
<el-table-column
prop="thesisLayoutUpdate"
label="添加日期" :formatter = 'dateFormat'
>
</el-table-column>
<el-table-column
label="操作"
>
<template slot-scope="scope">
  <a :href="scope.row.thesisLayoutContent"><el-button type="primary">下载</el-button></a>
</template>
</el-table-column>
</el-table>
<div class="block">
  <el-pagination
  @size-change="handleSizeChange"
  @current-change="handleCurrentChange"
  :current-page.sync="pageIndex"
  :page-size="pageSize"
  layout="prev, pager, next, jumper"
  :total="total">
</el-pagination>
</div>
</div>
</template>

<script>
//导入api接口
import { queryThesisLayout , downloadThesis} from '@/axios/api'
import { formatDate } from '@/common/js/date.js'
export default {
  data() {
    return {
      pageIndex:1,
      total:100,
      pageSize:10,
      tableData: [],
      fileList: []
    };
  },
  methods: {
    //时间格式化
    dateFormat:(row, column) => {
      let date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return formatDate(new Date(date), 'yyyy-MM-dd')
    },
  handleSizeChange: function(val) {
    console.log(`每页 ${val} 条`);
  },
  handleCurrentChange :function(val) {
    console.log(`当前页: ${val}`);
    this.pageIndex = val;
    this.getThesisLayoutList() ;
  },
    // downloadFile:function(row){
    //   let para = {
    //     thesisLayoutId : row.thesisLayoutId
    //   };
    //
    //   downloadThesis(para).then(res => {
    //     if (res.status == 200) {
    //       this.downloadPath = res.resData;
    //     } else {
    //         this.$message({
    //           showClose:true,
    //           message:'下载失败',
    //           type:'error'
    //         });
    //     }
    //   })
    // },
  getThesisLayoutList:function() {
    let param = {pageIndex: this.pageIndex};
  queryThesisLayout(param).then(res => {
      //this.goPage(this.pageIndex);
      console.log(res.resData.list);
      this.tableData = res.resData.list;
      // console.log(res.resData);
      this.total = res.resData.total;
      this.pageSize = res.resData.pageSize;

    })
  }
},

  //页面首次进入执行的方法
  mounted() {
    this.getThesisLayoutList();
  }
}
</script>
